package org.xtlgen;

import java.io.IOException;


/**
 * Main class for the XtlGen system. The user may optionally provide
 * a file name as argument and that file will be loaded.
 */
public class XtlGen {
  /**
   * Save arguments and schedule creation and display of the main frame
   * within Swing.
   *
   * @param args command line arguments given to the program.
   */
  public static void main(String args[]) throws IOException {
    // Schedule showFrame to run at a later time within Swing
    XtlGen.args = args;
    
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          XtlGen.showFrame();
        }
      });
  }

  /*
   * Create the main frame and display it
   */
  private static void showFrame() {
    //Create and set up the window.
    XtlGenFrame mainWindow = new XtlGenFrame(XtlGen.args.length > 0 ?
                                             XtlGen.args[0] : null);
    
    //Display the window.
    mainWindow.pack();
    mainWindow.setLocationRelativeTo(null);
    mainWindow.setVisible(true);
  }

  // Saved command line arguments
  private static String[] args;
}